import { buildProps, componentSize, definePropType } from '@/utils/props'
import { ExtractPropTypes, isVNode, StyleValue, VNodeChild } from 'vue'
import { isArray, isNumber, isString } from '@/utils/util'

export const spaceProps = buildProps({
  direction: {
    type: String,
    values: ['horizontal', 'vertical'],
    default: 'horizontal',
  },
  class: {
    type: definePropType<string | string[] | Record<string, boolean>>([String, Object, Array]),
    default: '',
  },
  style: {
    type: definePropType<StyleValue>([String, Object, Array]),
    default: ''
  },
  alignment: {
    type: definePropType<any>(String),
    default: 'center'
  },
  prefixCls: {
    type: String,
  },
  spacer: {
    type: definePropType<VNodeChild>([Object, String, Number, Array]),
    default: '',
    validator: (val: unknown) => isVNode(val) || isNumber(val) || isString(val)
  },
  wrap: {
    type: Boolean,
    default: false
  },
  fill: {
    type: Boolean,
    default: false
  },
  fillRatio: {
    type: Number,
    default: 100
  },
  size: {
    type: [String, Array, Number],
    values: componentSize,
    validator: (val: unknown): val is [number, number] | number => {
      return (
        isNumber(val) ||
        (isArray(val) && val.length === 2 && val.every((i) => isNumber(i)))
      )
    }
  }
} as const)
export type SpaceProps = ExtractPropTypes<typeof spaceProps>;

export default defineComponents({
  name:'ElSpace',
  props:spaceProps,
  setup(props,{slots}){


})
